package com.rzcode.coinex.kernel.service.impl;

import com.rzcode.coinex.kernel.common.mybatis.query.LambdaQueryWrapperPlus;
import com.rzcode.coinex.kernel.dao.entity.Coin;
import com.rzcode.coinex.kernel.dao.mapper.CoinMapper;
import com.rzcode.coinex.kernel.service.CoinService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class CoinServiceImpl implements CoinService {

    private final CoinMapper coinMapper;

    /**
     * 获取所有RPC币种
     */
    public List<String> findAllRpcUnit() {
        return coinMapper.findAllRpcUnit();
    }

    /**
     * 根据币种名称查询币种信息
     *
     * @param name
     * @return
     */
    @Override
    public Coin findOne(String name) {
        LambdaQueryWrapperPlus<Coin> wrapper = new LambdaQueryWrapperPlus<>();
        wrapper.eq(Coin::getName, name);
        return coinMapper.selectOne(wrapper);
    }
}
